//
//  LTMainViewController.swift
//  LTWeibo
//
//  Created by mac on 16/6/23.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class LTMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
//        创建自定义的tabBar 并通过KVC方式给只读属性的控件赋值
        let tabBar = LTTabbar()
        
        tabBar.addDelegate = self
        setValue(tabBar, forKey: "tabBar")
        

        addViewControllerToNav(LTHomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addViewControllerToNav(LTMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addViewControllerToNav(LTDiscoveryTableViewController(), title: "发现", imageName: "tabbar_discover")
        addViewControllerToNav(LTMineTableViewController(), title: "我的", imageName: "tabbar_profile")
        
   
        
        
        
    
    
    
    }
    
    
    
    func addViewControllerToNav(vc: UITableViewController, title: String, imageName: String) {
    
        
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imageName)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        let navC = UINavigationController(rootViewController: vc)
        addChildViewController(navC)
    
    }


}


extension LTMainViewController: LTTabbarDelegate{

    func addBtnClick() {
        print("代理实现跳转")
    }


}





